const utils=require('./../utils/utils.js');
const config=require('./../api/config.js');

const getSearchList=(val)=>{/* 搜索接口  */
  let keyWord = encodeURI(val);
  let url = config.URL.SEARCHLIST + keyWord + config.URL.SEARCHLIST_PM;

  return utils._request(url,'','GET');
}

const getLrc=(url)=>{/* 获取歌词 */
return utils._request(url,'','GET');
}
const getFile=(url)=>{/*下载歌曲文件 */
  let promise = new Promise((resolve, reject)=>{
    let config = {
      url: url,
      success: function (res) {
        resolve(res);
      },
      fail: function (err) {
        reject(config.CONST.ERR_E+JSON.stringify(err));
      }
    };
    
    wx.downloadFile(config);
  })
  return promise;
}

module.exports={
  getSearchList,
  getLrc,
  getFile
}